import java.util.ArrayList;
import java.util.List;

public class Solution1169 {
    public List<String> invalidTransactions(String[] transactions) {
        boolean[] f=new boolean[transactions.length];
        for (int i=0;i<transactions.length;i++){
            String[] strings=transactions[i].split(",");
            if (Integer.parseInt(strings[2])>1000){
                f[i]=true;
            }else{
                for (int j=0;j<transactions.length;j++){
                    if (i!=j){
                        String[] strings1=transactions[j].split(",");
                        if (strings[0].equals(strings1[0]) && Math.abs(Integer.parseInt(strings[1]) - Integer.parseInt(strings1[1])) <= 60 && !strings[3].equals(strings1[3])){
                            f[i]=true;
                            break;
                        }
                    }
                }
            }
        }
        List<String> ans=new ArrayList<>();
        for (int i=0;i<transactions.length;i++){
            if (f[i]){
                ans.add(transactions[i]);
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1169().invalidTransactions(new String[]{"alice,20,800,mtv","alice,50,100,beijing"}));
    }
}
